package no.ntnu.fp.handlers;

import no.ntnu.fp.handler.Handler;
import no.ntnu.fp.messages.Message;
import no.ntnu.fp.messages.impl.MeetingUpdatedMessage;
import no.ntnu.fp.model.CalendarModel;
import no.ntnu.fp.model.Meeting;

public class MeetingUpdatedHandler implements Handler {
	private final CalendarModel calendarModel;
	
	public MeetingUpdatedHandler(CalendarModel calendarModel) {
		this.calendarModel = calendarModel;
	}

	@Override
	public void handleMessage(Message message) {
		MeetingUpdatedMessage meetingUpdatedMessage 
											= (MeetingUpdatedMessage) message;
		
		Meeting meeting = meetingUpdatedMessage.getMeeting();
		calendarModel.addOrUpdateMeeting(meeting.getEmployee(), meeting);
	}

}
